package com.xuecheng.system.controller;

import com.xuecheng.system.model.po.Dictionary;
import com.xuecheng.system.service.IDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author itcast
 */
@RestController
@RequestMapping("/dictionary")
@RequiredArgsConstructor
@Api(value = "数据字典管理", tags = "数据字典管理")
public class DictionaryController  {

    private final IDictionaryService dictionaryService; // 数据字典服务

    /**
     * 查询所有数据字典
     * @return List<Dictionary> 数据字典集合
     */
    @GetMapping("/all")
    @ApiOperation("查询所有数据字典")
    public List<Dictionary> queryAll() {
        return dictionaryService.queryAll();
    }

    /**
     * 根据字典编码查询字典
     * @param code 字典编码
     * @return Dictionary 字典
     */
    @GetMapping("/code/{code}")
    @ApiOperation("根据字典编码查询字典")
    public Dictionary getByCode(@PathVariable String code) {
        return dictionaryService.getByCode(code);
    }
}
